package com.zhipu.resetbalance.pop.Intranet;

import android.content.Context;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.SPUtils;
import com.lxj.xpopup.core.CenterPopupView;
import com.zhipu.resetbalance.R;
import com.zhipu.resetbalance.utils.InitializeUtils;

/**
 * 内网设置
 */
public class IntranetSettingsPopup extends CenterPopupView {



    public IntranetSettingsPopup(@NonNull Context context) {
        super(context);
    }


    @Override
    protected int getImplLayoutId() {

        return R.layout.popup_intranet_settings;
    }


    @Override
    protected void onCreate() {
        super.onCreate();
        EditText mNetworkSettings = findViewById(R.id.NetworkSettings);
        String networkSettings = SPUtils.getInstance().getString("NetworkSettings","");
        mNetworkSettings.setText(networkSettings);
        /**
         * 取消
         */
        findViewById(R.id.Cancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //隐藏软键盘
                KeyboardUtils.hideSoftInput(mNetworkSettings);
                dismiss();
            }
        });
        /**
         * 确认添加
         */
        findViewById(R.id.ConfirmAdd).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String addressNetworkSettings = mNetworkSettings.getText().toString();
                SPUtils.getInstance().put("NetworkSettings", addressNetworkSettings);
                InitializeUtils.getDefaultMaker().show("修改成功,可以上传了");
                //隐藏软键盘
                KeyboardUtils.hideSoftInput(mNetworkSettings);
                dismiss();
            }
        });
    }
}
